#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 55;
int a[N];
typedef long long ll;
int main() {
  int t;
  cin >> t;

  while (t--) {
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum == 1LL * n) {
      cout << "0\n";
    } else if (sum <= 1LL * n) {
      cout << "1\n";
    } else {
      cout << sum - n << endl;
    }
  }
}
